package Servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import anonymus.excepcion.DAOExcepcion;
import anonymus.negocio.ServicioNegocio;

/**
 * Servlet implementation class RegistrarServicioServlet
 */
@WebServlet("/RegistrarServicioServlet")
public class RegistrarServicioServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegistrarServicioServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	
		ServicioNegocio neg = new ServicioNegocio();
		
//		String local = request.getParameter("cboNombreLocal");
//		String codServicio = request.getParameter("servi");
		
		
		
		String TipoServicio = request.getParameter("txtTipoServicio");
		String Descripcion = request.getParameter("txtDescripcionServicio");
		double tarifa = Double.parseDouble(request.getParameter("txtTarifaServicio"));
			
		
		
			if(TipoServicio!=null || Descripcion != null || tarifa!=' ' )
			{
             try {
                     neg.insertarServicio(TipoServicio, Descripcion, tarifa);
//                   neg.insertarLocalServicio(local,codServicio);
                     
                     System.out.println("Grabado Satisfactoriamente");
                     
                     response.sendRedirect(request.getContextPath() + "/Local.jsp");
                     
                     
             } catch (DAOExcepcion e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
		
             }
	}
			else{
				System.out.println("Faltan llenar datos");
			}
	}	
}


